package systempen.cmanager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;


public class Splash extends Activity {
	private Thread mSplashThread;
	public Activity thisclass;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.splash);
        thisclass =  this;

        try{
        } catch(Exception ex){
        	
        }
        //final Splash sPlashScreen = this;   
        
        // The thread to wait for splash screen events
        mSplashThread =  new Thread(){
            @Override
            public void run(){
                try {
                    synchronized(this){
                        // Wait given period of time or exit on touch
                        wait(100);
                    }
                }catch(InterruptedException ex){                    
                }
                finish();
                //stop();
                if (util.PasswordExists(getApplicationContext()))
                {
                	startActivity(new Intent(thisclass, PasswordWall.class));
                }else
                	startActivity(new Intent(thisclass, MainActivityTab.class));
            }
        };
        mSplashThread.start();        
    }
    /**
     * Processes splash screen touch events
     */
    @Override
    public boolean onTouchEvent(MotionEvent evt)
    {
        if(evt.getAction() == MotionEvent.ACTION_DOWN)
        {
            synchronized(mSplashThread){
                mSplashThread.notifyAll();
            }
        }
        return true;
    }    
} 